feat: add natural language search#94
Merged
kishorenc merged 2 commits intotypesense:masterfrom Aug 11, 2025
Merged
Conversation
- add `NLSearchModel` class for individual model operations (retrieve, update, delete) - add `NLSearchModels` class for collection operations (create, retrieve, __getitem__) - add type definitions in `types/nl_search_model.py` with support for multiple llm providers - integrate `nl_search_models` into main `Client` class with proper imports - add test fixtures and tests for both individual and collection operations
- add `NLLanguageParameters` type with nl query configuration options - add `LLMResponse` and `ParsedNLQuery` types for nl query responses - extend `SearchParameters` to include natural language parameters - add `parsed_nl_query` field to `SearchResponse` for nl query metadata
kishorenc
approved these changes
Aug 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Add NL query parameters to search API and complete NL search models CRUD operations.
Change Summary
Added Features:
New Natural Language Query Support in
src/typesense/types/document.py:NLLanguageParameters: Configuration for natural language queries with caching, model selection, and debug optionsLLMResponse: Schema for raw LLM responses with content, extraction method, and model infoParsedNLQuery: Schema for processed NL queries with timing, generated/augmented parameters, and LLM responseSearchParametersto includeNLLanguageParametersparsed_nl_queryfield toSearchResponsefor NL query metadataNew NL Search Models Management System:
NLSearchModelclass insrc/typesense/nl_search_model.py: Individual model operations (retrieve, update, delete)NLSearchModelsclass insrc/typesense/nl_search_models.py: Collection operations (create, retrieve, getitem)src/typesense/types/nl_search_model.py: Support for multiple LLM providers (OpenAI, Google, GCP Vertex AI, Cloudflare)Code Changes:
In
src/typesense/client.py:NLSearchModelsinto mainClientclass with proper importsself.nl_search_models = NLSearchModels(self.api_call)to client initializationIn
tests/fixtures/nl_search_model_fixtures.py:In
tests/nl_search_model_test.pyandtests/nl_search_models_test.py: